(define (even? n) (= (remainder n 2) 0))

; Integration with Simpson's rule
; f - function to be integrated
; a - start of interval
; b - end of interval
; n - number of steps
(define (integral f a b n)
  ; length of subintervals
  (define h (/ (- b a) n))
  (define (y k) (f (+ a (* k h))))
  (define (sum-y start stop acc)
    (if (> start stop) acc
        (sum-y (+ start 2) stop (+ acc (y start)))))
  (define sum-even (* 2 (sum-y 2 (- n 2) 0)))
  (define sum-odd  (* 4 (sum-y 1 (- n 1) 0)))
  (/ ( * h (+ (f a) (f b) sum-even sum-odd)) 3))
